#pragma GCC optimize(2)
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <map>
#include <vector>
#include <set>

using namespace std;
using LL = long long;
const int N = 2e5 + 10;

int n, q;
int a[N], b[N];
int ok[N][2];
set<int> stA, stB;
set<int> compA, compB;


void f(int i, int j){
    if(compA.empty() && compB.empty()){
            if(ok[i][0] == -1){
                ok[i][0] = j;
                ok[i][1] = j;
            }else{
                ok[i][1] = max(ok[i][1], j);
            }
        }
}


void f1(int i, int jl, int jr){
    
}


int main(){
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    cin >> n;
    for(int i = 1; i <= n; i ++){
        cin >> a[i];

    }
    for(int i = 1; i <= n; i ++){ 
        cin >> b[i];

    }

    for(int i = 0; i <= n; i ++) ok[i][0] = ok[i][1] = -1;


    int i = 1, j = 0;
    bool flag = false;
    while(true){
        if(flag) break;
        

        if(compA.empty() && compB.empty()){

            int tempj = j + 1;
            while(stB.count(b[tempj]) && tempj <= n){
                f(i, tempj);
                tempj ++;
            }

            


            
            while(stA.count(a[i]) && i <= n){
                ok[i][0] = j;
                ok[i][1] = tempj - 1;
                i ++;
            }
            if(i <= n){
                stA.insert(a[i]);
                compA.insert(a[i]);
            }else{
                flag = true;
                break;
            }

            j = tempj - 1;

        }


        while(!compB.empty() && i <= n){
            i ++;
            if(stA.count(a[i])){
                f(i, j);
                continue;
            }

            stA.insert(a[i]);

            if(compB.count(a[i])){
                compB.erase(a[i]);
                f(i, j);
            }else{
                compA.insert(a[i]);
            }


        }


        if(!compB.empty() && i > n){
            flag = true;
            break;
        }

        while(!compA.empty() && j <= n){
            j ++;

            if(stB.count(b[j])){
                f(i, j);
                continue;
            }

            stB.insert(b[j]);

            if(compA.count(b[j])){
                compA.erase(b[j]);
                f(i, j);
            }else{
                compB.insert(b[j]);
            }
        }


        if(!compA.empty() && j > n){
            flag = true;
            break;
        }

        
    }


    cin >> q;
    while (q--){
        int l, r;
        cin >> l >> r;

        if(ok[l][0] != -1 && ok[l][1] != -1 && r >= ok[l][0] && r <= ok[l][1]){
            cout << "Yes" << '\n';
        }else{
            cout << "No" << '\n';
        }
    }
    


    return 0;
}